<template>
  <div>
    <!-- 提现 -->
    <div class="header">
      <van-sticky>
        <van-nav-bar
          title="提现界面"
          left-text="返回"
          left-arrow
          @click-left="onClickLeft"
        />
      </van-sticky>
    </div>
    <!-- {{userid}} -->
    <van-field
      type="number"
      placeholder="请输入提现金额"
      clearable
      @click="showHandler"
      :value="keyboardInput"
      v-model="keyboardInput"
    >
    </van-field>
    <van-button type="primary" block @click="rechage(keyboardInput)"
      >提 现</van-button
    >
    <van-number-keyboard
      :show="show"
      theme="custom"
      extra-key="."
      @blur="show = false"
      close-button-text="完成"
      @delete="onDelete"
      v-model="keyboardInput"
      type="number"
    />
  </div>
</template>

<script>
import { get, post } from "@/http/axios";
export default {
  data() {
    return {
      // 键盘显示
      show: false,
      //键盘输入内容
      keyboardInput: "",
      //用户id
      userid: this.$route.query.userid,
    };
  },
  methods: {
    //返回功能
    onClickLeft() {
      this.$router.push({
        path: "/manager/mine",
      });
    },

    // 键盘删除按钮
    onDelete() {},
    // 关闭键盘函数
    CloseKeyboard() {
      this.show = false;
    },
    //展示键盘
    showHandler() {
      this.show = true;
    },
    //提现功能
    async rechage(keyboardInput) {
      // console.log(this.keyboardInput);
      // console.log(this.userid);
      if (this.keyboardInput <= 0) {
        this.$toast.fail("输入的金额要大于0");
      } else {
        let obj = {
          money: this.keyboardInput,
          applyType: "提现",
          userId: this.userid,
        };
        let res = await post("/accountApply/submitAccountApply", obj);
        // console.log(res);
        this.$toast.success("充值成功");
        this.$router.push({
          path: "/manager/help",
        });
      }
    },
  },
  created() {},
};
</script>

<style scoped>
</style>